<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>短视频APP-管理系统</title>
        <meta name="keywords" content="短视频APP-管理系统">
        <meta name="description" content="">
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="{$sys_url.static}layui/css/layui.css" media="all">
        <style>
            .frameContent {padding:30px 30px 0px 0px}
            .roleList {float:left;margin:5px 0px;width:33%}
            .frameBtn {text-align:center;margin:20px 0px 0px 30px;padding-top:20px;border-top:1px rgb(204,204,204) dashed}
        </style>
    </head>
    <body>
        <div>
            <form class="layui-form frameContent">

                <div class="layui-form-item">
                    <div class="layui-form-label">开发者ID</div>
                    <div class="layui-input-block">
                        <input type="text" name="appid" value="自动生成" required lay-verify="required" placeholder="请输入开发者ID" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-form-label">开发者密码</div>
                    <div class="layui-input-block">
                        <input type="text" name="appsecret" value="自动生成" required lay-verify="required" placeholder="请输入开发者秘钥" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="frameBtn">
                    <button class="layui-btn" lay-submit lay-filter="submit">确定新增</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </form>
        </div>
    </body>
    <script src="{$sys_url.static}layui/layui.js" charset="utf-8"></script>
    <script>

        layui.use(['layer','layedit', 'form','jquery'],function() {
            var form = layui.form, layer = layui.layer;
            var $ = layui.$;
            var layedit = layui.layedit;
            var index = layedit.build('demo'); //建立编辑器
            form.verify({
                content: function (value) {
                    return layedit.sync(index);
                }
            });
        });

        layui.use(['form'], function() {
            var form = layui.form;
            var $ = layui.jquery;


            //监听提交
            form.on('submit(submit)', function(data) {
                layer.confirm('是否确定新增？', {icon: 3, title: '系统信息'}, function(index) {
                    $.ajax({
                        url: '{$sys_url.ctr}/add_ajax',
                        type: 'post',
                        data: data.field,
                        dataType: "json",
                        beforeSend: function() {
                            console.log(JSON.stringify(data.field));
                        },
                        success: function(data) {
                            //do something
                            console.log(data);
                            if (data.code == 1) {
                                var index = parent.layer.getFrameIndex(window.name);
                                //获取当前窗口索引
                                parent.layer.msg('添加成功', {icon: 1});
                                parent.layer.close(index);
                                window.parent.location.reload();
                                //重新加载父级tabel数据
                            } else {
                                layer.alert(data.msg, {icon: 2});
                            }
                        },
                        error: function(data) {
                            //do something
                            console.log(data);
                            layer.msg('与服务器连接失败', {icon: 2});
                        }
                    });
                    layer.close(index);
                });
                return false;
            });
        });
    </script>
</html>